package net.lab1024.sa.admin.module.business.oa.reservation.controller;

import net.lab1024.sa.admin.module.business.oa.reservation.domain.form.ReservationAddForm;
import net.lab1024.sa.admin.module.business.oa.reservation.domain.form.ReservationQueryForm;
import net.lab1024.sa.admin.module.business.oa.reservation.domain.form.ReservationQueryFormPub;
import net.lab1024.sa.admin.module.business.oa.reservation.domain.form.ReservationUpdateForm;
import net.lab1024.sa.admin.module.business.oa.reservation.domain.vo.ReservationVO;
import net.lab1024.sa.admin.module.business.oa.reservation.service.ReservationService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.List;

/**
 * 预约记录 Controller
 *
 * @Author TianYuan
 * @Date 2025-07-22 16:21:55
 * @Copyright TianYuan
 */

@RestController
@Tag(name = "预约记录")
public class ReservationController {

    @Resource
    private ReservationService reservationService;

    @Operation(summary = "分页查询 @author TianYuan")
    @PostMapping("/oa/reservation/queryPage")
    @SaCheckPermission("oa:reservation:query")
    public ResponseDTO<PageResult<ReservationVO>> queryPage(@RequestBody @Valid ReservationQueryForm queryForm) {
        return ResponseDTO.ok(reservationService.queryPage(queryForm));
    }

    @NoNeedLogin
    @Operation(summary = "分页查询 @author TianYuan")
    @PostMapping("/oa/reservation/queryPage4public")
    public ResponseDTO<List<ReservationVO>> queryPage4public(@RequestBody @Valid ReservationQueryFormPub queryForm) {
        return ResponseDTO.ok(reservationService.queryPage4public(queryForm));
    }

    @Operation(summary = "添加 @author TianYuan")
    @PostMapping("/oa/reservation/add")
    @SaCheckPermission("oa:reservation:add")
    public ResponseDTO<String> add(@RequestBody @Valid ReservationAddForm addForm) {
        return reservationService.add(addForm);
    }

    @NoNeedLogin
    @Operation(summary = "添加 @author TianYuan")
    @PostMapping("/oa/reservation/add4public")
    public ResponseDTO<String> add4public(@RequestBody @Valid ReservationAddForm addForm) {
        return reservationService.add(addForm);
    }

    @Operation(summary = "更新 @author TianYuan")
    @PostMapping("/oa/reservation/update")
    @SaCheckPermission("oa:reservation:update")
    public ResponseDTO<String> update(@RequestBody @Valid ReservationUpdateForm updateForm) {
        return reservationService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author TianYuan")
    @PostMapping("/oa/reservation/batchDelete")
    @SaCheckPermission("oa:reservation:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return reservationService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author TianYuan")
    @GetMapping("/oa/reservation/delete/{reservationId}")
    @SaCheckPermission("oa:reservation:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long reservationId) {
        return reservationService.delete(reservationId);
    }


    @Operation(summary = "预约确认 @author TianYuan")
    @GetMapping("/oa/reservation/confirm/{reservationId}")
    @SaCheckPermission("oa:reservation:confirm")
    public ResponseDTO<String> reservationConfirm(@PathVariable Long reservationId) {
        return reservationService.reservationConfirm(reservationId);
    }

}
